package com.pingan.haofang.searchcloud.monitor.dao;

import com.pingan.haofang.searchcloud.monitor.domain.DashboardErrorSql;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * @author EX-SUNBIXIAO001
 * @date 2018/10/23
 * @since 1.0.0
 */
@Repository
public interface DashboardErrorSqlDao extends JpaRepository<DashboardErrorSql, Long>,CrudRepository<DashboardErrorSql,Long> {

    @Query("select t from DashboardErrorSql t where t.indexId=:indexId and t.type=2 and t.queryCost>3000"+
            "and t.queryTime >= :date and t.queryTime<:date1")
    List<DashboardErrorSql> slowQuerySqlDeatilByIndexId(@Param("indexId") Long indexId, @Param("date")Date date,
                                               @Param("date1")Date date1);


    @Query("select t from DashboardErrorSql t where t.projectId=:projectId and t.type=2 and t.queryCost>3000"+
            "and t.queryTime >= :date and t.queryTime<:date1")
    List<DashboardErrorSql> slowQuerySqlDeatilByProjectId(@Param("projectId") Long projectId, @Param("date")Date date,
                                               @Param("date1")Date date1);


}
